@echo off
echo ========================================
echo    Windows Simple Deployment Script
echo ========================================

:: 停止现有应用
echo Stopping existing application...
call pm2 stop my-app >nul
call pm2 delete my-app >nul

:: 清理并创建部署目录
:: if exist "deploy" rmdir /s /q "deploy"
:: mkdir deploy

:: 复制文件（排除不需要的目录）
echo Copying files...
:: xcopy /E /I /Y /EXCLUDE:deploy-exclude.txt . deploy\

:: 安装依赖
echo Installing dependencies...
cd deploy
call pnpm install

:: 启动应用
echo Starting application...
call pm2 start app.js --name my-app --env production

:: 保存 PM2 配置
call pm2 save

echo ========================================
echo    Deployment Completed Successfully!
echo ========================================
pause